
from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
service = Service(executable_path="E:\python\python38\chromedriver.exe")
driver = webdriver.Chrome(service=service)
driver.get("http://121.43.169.97:8848/pageA.html")
action = ActionChains(driver)
driver.maximize_window()
sleep(5)

# 需求：打开注册A页面，完成以下操作
# 1). 输入用户名：admin1，暂停2秒，删除1
username=driver.find_element(By.CSS_SELECTOR,"#userA")
username.send_keys("admin")
#暂停2秒
sleep(2)
#删除1
username.send_keys(Keys.BACK_SPACE)

# 2). 全选用户名：admin，暂停2秒
username.send_keys(Keys.CONTROL,"a")
#暂停2秒
sleep(2)

# 3). 复制用户名：admin，暂停2秒
username.send_keys(Keys.CONTROL,"c")
#暂停2秒
sleep(2)


# 4). 粘贴到密码框
passwoed =driver.find_element(By.CSS_SELECTOR,"#passwordA")
passwoed.send_keys(Keys.CONTROL,'v')


sleep(6)
driver.quit()